//
//  ZGSCartoonFriendCell.m
//  MapleLeaf
//
//  Created by 邝子涵 on 15/12/1.
//  Copyright © 2015年 AntennaBabyTeam. All rights reserved.
//

#import "ZGSCartoonFriendCell.h"

@implementation ZGSCartoonFriendCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    // 背景View
    self.backView = [[UIView alloc] init];
    self.backView.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
    self.backView.layer.borderWidth = 1;
    self.backView.layer.borderColor = [UIColor clearColor].CGColor;
    self.backView.layer.cornerRadius = 3;
    self.backView.layer.shadowOffset = CGSizeMake(0, 0);
    self.backView.layer.shadowColor = [UIColor blackColor].CGColor;
    self.backView.layer.shadowOpacity = 0.5;
    self.backView.layer.shadowRadius = 1;
    [self.contentView addSubview:self.backView];
    
    // 头像
    self.iconImageView = [[UIImageView alloc] init];
    self.iconImageView.backgroundColor = [UIColor yellowColor];
    self.iconImageView.layer.borderWidth = 1;
    self.iconImageView.layer.cornerRadius = 27.5;
    self.iconImageView.layer.masksToBounds = YES;
    self.iconImageView.layer.borderColor = [UIColor clearColor].CGColor;
    [self.backView addSubview:self.iconImageView];
    
    
    // 昵称
    self.nickNameLabel = [[UILabel alloc] init];
    self.nickNameLabel.textColor = [UIColor colorWithRed:0.057 green:0.5163 blue:0.9031 alpha:1.0];
    self.nickNameLabel.font = [UIFont systemFontOfSize:14.];
    [self.backView addSubview:self.nickNameLabel];
    
    
    // 标题
    self.contentLabel = [[UILabel alloc] init];
    self.contentLabel.backgroundColor = [UIColor colorWithRed:0.9211 green:0.921 blue:0.9211 alpha:0.5];
    self.contentLabel.layer.borderWidth = 1;
    self.contentLabel.layer.cornerRadius = 5;
    self.contentLabel.layer.borderColor = [UIColor clearColor].CGColor;
    self.contentLabel.layer.masksToBounds = YES;
    self.contentLabel.font = [UIFont systemFontOfSize:15.];
    self.contentLabel.numberOfLines = 0;
    [self.contentLabel sizeToFit];
    [self.backView addSubview:self.contentLabel];
    
    
    // 图片
    self.picImageView = [[UIImageView alloc] init];
    self.picImageView.backgroundColor = [UIColor lightGrayColor];
    self.picImageView.layer.borderWidth = 1;
    self.picImageView.layer.borderColor = [UIColor clearColor].CGColor;
    self.picImageView.layer.cornerRadius = 5;
    self.picImageView.layer.shadowOffset = CGSizeMake(0, 0);
    self.picImageView.layer.shadowColor = [UIColor blackColor].CGColor;
    self.picImageView.layer.shadowOpacity = 0.8;
    self.picImageView.layer.shadowRadius = 1;
    [self.backView addSubview:self.picImageView];
    
    // 添加手势
//    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click:)];
//    [_picImageView addGestureRecognizer:tap];
    
    
    self.upConuntLabel = [[UILabel alloc] init];
    self.upConuntLabel.font = [UIFont systemFontOfSize:12.5];
    self.upConuntLabel.textColor = [UIColor lightGrayColor];
    [self.backView addSubview:self.upConuntLabel];
    
    self.reCountLabel = [[UILabel alloc] init];
    self.reCountLabel.textColor = [UIColor lightGrayColor];
    self.reCountLabel.font = [UIFont systemFontOfSize:12.5];
    [self.backView addSubview:self.reCountLabel];
    
    self.readCountLabel = [[UILabel alloc] init];
    self.readCountLabel.textColor = [UIColor lightGrayColor];
    self.readCountLabel.font = [UIFont systemFontOfSize:12.5];
    [self.backView addSubview:self.readCountLabel];
    
}

//#pragma mark - 图片手势点击方法
//- (void)click:(UITapGestureRecognizer *)tap{
//    NSLog(@"我点击图片的");
//    
//}



- (void)setFriendSonModel:(ZGSCartoonfriendSonModel *)friendSonModel{
    if (_friendSonModel != friendSonModel) {
        _friendSonModel = friendSonModel;
        
        // cell 赋值
        self.contentLabel.text = friendSonModel.content;
        self.nickNameLabel.text = friendSonModel.nickName;
        [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:friendSonModel.icon] placeholderImage:nil];
        self.upConuntLabel.text = [NSString stringWithFormat:@" 赞: %@",friendSonModel.upCount];
        self.reCountLabel.text = [NSString stringWithFormat:@" 评论: %@", friendSonModel.commentCount];
        self.readCountLabel.text = [NSString stringWithFormat:@" 阅读: %@", friendSonModel.readCount];
    }
    
    
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
